import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

const state = {
	openid:window.OPEN_DATA.openid,
    platform:window.OPEN_DATA.platform,
    openkey:window.OPEN_DATA.openkey,
	backpack:[],
	isLogin:true,//判断是否登录
	userInfo:{},
	address:{},
	isIphoneX:false,
	isnew:false,
    // userInfo:{
    //   uid:"52236",
    //   nickname:"188****8888",
    //   avatar:"http://api.mxzhuawawa.com/style/app/avatar.png",
    //   coinbalance:"9471.00",
    //   token:"5d95f9d4ba753a6ab9748d27a93bab8c",
    //   is_register:1,
    // },
}

const getters ={
	user:state => state.userInfo,
	platform:state => state.platform,
	isIphoneX:state => state.isIphoneX,
	getNew:state => state.isnew,
}




const mutations ={
	go(state,s){
		console.log(s)
		s[0].push({path:'/'+s[1]})
	},
	getUserinfo(state,data){
		state.userInfo=data;
	},
	getCoinInfo(state,data){
		state.userInfo.coinbalance = data;
	},
	isIphoneX(state,data){
		state.isIphoneX = data;
	},
	getRegister(state,data){
		state.isnew = data;
	},
}

export default new Vuex.Store({
	state,
	getters,
	mutations
})
